
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    HttpSession session1 = request.getSession(false);
    if (session1 == null || session1.getAttribute("id") == null) {
        response.sendRedirect(request.getContextPath() + "/index.jsp");
    }
%>
<title>搜索好友</title>
<div style="text-align: center">
    请输入需要查找的id:<input name="user_name" type="text" id="user_name" style="text-align: center">
    <input type="submit" value="查找" onclick="judgment()" style="text-align: center">
</div>

<script type="text/javascript">
    let reg10 = /^\d{1,9}$/;
    function judgment() {
        let user_name = document.getElementById("user_name").value;
        if (!reg10.test(user_name)) {
            alert("您输入的名字格式不对,输入数字");
            return false;
        }
        var xmlHttp = new XMLHttpRequest();
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                alert(xmlHttp.responseText);
            }
        }
        var param = "user_name=" + user_name;
        xmlHttp.open("post", "selectFriend?" + param, true);
        xmlHttp.send();
    }
</script>
<style>
    body{
        background-image: url("picture/new.jpg");
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-position: center center;
        background-size: 100% 100%;
    }
</style>
